﻿Imports Equipment.Core
Imports Equipment.DataAccess
Imports Equipment.Business
Imports Equipment.Model

Namespace Equipment
    <RequiresPageAcces(Page:=PageType.BasicRequirementsSetup)> _
    Public Class BasicRequirementsController
        Inherits System.Web.Mvc.Controller

        '
        ' GET: /BasicRequirements
        <RequiresPageAcces(Page:=PageType.BasicRequirementsSetup)> _
        Function Index() As ActionResult
            ViewData("AssetType") = New SelectList(AssetType.RetrieveAll(), "ID", "Description")
            ViewData("Role") = New SelectList(Role.RetrieveAll(), "ID", "Description")
            ViewData("EntityType") = EntityType.Requirement
            ViewData("Requirements") = Requirement.RetrieveAll()
            Return View()
        End Function

        <HttpPost()> _
        Function Index(ByVal collection As FormCollection) As ActionResult
            Return View("Create")
        End Function

#Region "Edit"
        Function Edit(ByVal id As Integer) As ActionResult
            Dim reqToEdit As Requirement = Requirement.GetByPrimaryKey(id)

            If reqToEdit IsNot Nothing Then
                InitControls(reqToEdit)
            End If

            Return View()
        End Function

        <HttpPost()> _
        Function Edit(ByVal id As Integer, ByVal collection As FormCollection) As ActionResult
            Dim reqToEdit As Requirement = Requirement.GetByPrimaryKey(id)

            Dim roles = Role.RetrieveAll()
            Dim formMaxId As Integer = Integer.Parse(collection("maxId"))
            Dim formRequirementName As String = collection("RequirementName")
            Dim formRequirementType As RequirementType = [Enum].Parse(GetType(RequirementType), collection("RequirementType"))
            Dim formAssetTypeID As Integer = Integer.Parse(collection("AssetType"))
            Dim formFrequencyType As RequirementFrequency = [Enum].Parse(GetType(RequirementFrequency), collection("rbFrequency"))
            Dim formUseNotHolidayWeekday As Boolean = Boolean.Parse(collection("cbxNotHolidayWeekday").Split(",")(0))
            Dim formUseSaturdays As Boolean = Boolean.Parse(collection("cbxSaturdays").Split(",")(0))
            Dim formUseSundays As Boolean = Boolean.Parse(collection("cbxSundays").Split(",")(0))
            Dim formUseHoliday As Boolean = Boolean.Parse(collection("cbxHoliday").Split(",")(0))

            Dim changeDetails As New List(Of String)

            Dim formFrequency As String
            Dim formFrequencyDueEnd As String

            Dim oldFrequencyDueEnd As String = If(reqToEdit.FrequencyDueEnd, String.Empty)

            Dim oldAssetType As String = reqToEdit.AssetType.Description

            Try
                If String.IsNullOrEmpty(formRequirementName) Then
                    ModelState.AddModelError("RequirementName", "Basic Requirement Name is required.")
                End If

                If reqToEdit.Name <> formRequirementName Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_MODIFICATION_TEMPLATE, "Requirement Name", reqToEdit.Name, formRequirementName))
                End If

                If reqToEdit.Type <> formRequirementType Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_MODIFICATION_TEMPLATE, "Requirement Type", reqToEdit.Type, formRequirementType))
                End If

                If reqToEdit.FrequencyType <> formFrequencyType Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_MODIFICATION_TEMPLATE, "Frequency", reqToEdit.FrequencyType, formFrequencyType))
                End If

                If reqToEdit.UseNotHolidayWeekday <> formUseNotHolidayWeekday Then
                    If formUseNotHolidayWeekday Then
                        changeDetails.Add("Weekdays that are not holidays was checked")
                    Else
                        changeDetails.Add("Weekdays that are not holidays was unchecked")
                    End If
                End If

                If reqToEdit.UseSundays = formUseSundays Then
                    If formUseNotHolidayWeekday Then
                        changeDetails.Add("Sundays was checked")
                    Else
                        changeDetails.Add("Sundays was unchecked")
                    End If
                End If

                If reqToEdit.UseSaturdays = formUseSaturdays Then
                    If formUseNotHolidayWeekday Then
                        changeDetails.Add("Saturdays was checked")
                    Else
                        changeDetails.Add("Saturdays was unchecked")
                    End If
                End If

                If reqToEdit.UseHoliday = formUseHoliday Then
                    If formUseNotHolidayWeekday Then
                        changeDetails.Add("Holidays was checked")
                    Else
                        changeDetails.Add("Holidays was unchecked")
                    End If
                End If

                reqToEdit.Name = formRequirementName
                reqToEdit.AssetType = reqToEdit.DBContext.AssetTypes.Single(Function(t) t.ID = formAssetTypeID)
                reqToEdit.Type = formRequirementType
                reqToEdit.FrequencyType = formFrequencyType
                reqToEdit.UseNotHolidayWeekday = formUseNotHolidayWeekday
                reqToEdit.UseSundays = formUseSundays
                reqToEdit.UseSaturdays = formUseSaturdays
                reqToEdit.UseHoliday = formUseHoliday

                Dim existingMeasureIDs = reqToEdit.Measures.ToDictionary(Function(m) m.ID)

                reqToEdit.Measures.Clear()

                For i As Integer = 1 To formMaxId

                    Dim formMeasureName As String = collection(String.Format("measureName_{0}", i))

                    If Not String.IsNullOrEmpty(formMeasureName) Then

                        Dim measure As New RequirementMeasure()

                        Dim formMeasureID As String = collection(String.Format("measureID_{0}", i))
                        Dim formMeasureOptimalLookupValue As String = collection(String.Format("measureOptimalLookupValue_{0}", i))
                        Dim formMeasureOptimalMin As String = collection(String.Format("measureOptimalMin_{0}", i))
                        Dim formMeasureOptimalMax As String = collection(String.Format("measureOptimalMax_{0}", i))
                        Dim formMeasureType As MeasureType = [Enum].Parse(GetType(MeasureType), collection(String.Format("measureType_{0}", i)))
                        Dim formMeasureLookupValue As String = collection(String.Format("measureLookupValue_{0}", i))
                        Dim formMeasureRequiredComments As String = collection(String.Format("measureRequiredComments_{0}", i))

                        measure.MeasureDescription = formMeasureName
                        measure.MeasureType = CInt(formMeasureType)
                        measure.LookupValue = formMeasureLookupValue
                        measure.OptimalLookupValue = formMeasureOptimalLookupValue

                        If formMeasureType = MeasureType.Integer Then
                            measure.IntegerMin = Integer.Parse(formMeasureOptimalMin)
                            measure.IntegerMax = Integer.Parse(formMeasureOptimalMax)
                        ElseIf formMeasureType = MeasureType.Decimal Then
                            measure.DecimalMin = Decimal.Parse(formMeasureOptimalMin)
                            measure.DecimalMax = Decimal.Parse(formMeasureOptimalMax)
                        End If

                        measure.RequiredComments = Integer.Parse(formMeasureRequiredComments)

                        reqToEdit.Measures.Add(measure)

                        If String.IsNullOrEmpty(formMeasureID) Then
                            Dim mid As Integer
                            If Integer.TryParse(formMeasureID, mid) Then
                                If mid <> 0 AndAlso Not existingMeasureIDs.ContainsKey(mid) Then
                                    changeDetails.Add(String.Format("Added measure '{0}'", formMeasureName))
                                End If
                            End If
                        End If

                    End If

                Next

                reqToEdit.FirstTime = New Nullable(Of DateTime)
                reqToEdit.SecondTime = New Nullable(Of DateTime)

                If formFrequencyType = RequirementFrequency.EveryXHours Then
                    formFrequency = collection("txtEveryXHours")
                    formFrequencyDueEnd = collection("txtEveryXHoursDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        reqToEdit.Frequency = Integer.Parse(formFrequency)
                        reqToEdit.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXWeeks Then
                    formFrequency = collection("txtEveryXWeeks")
                    formFrequencyDueEnd = collection("txtEveryXWeeksDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        reqToEdit.Frequency = Integer.Parse(formFrequency)
                        reqToEdit.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXYears Then
                    formFrequency = collection("txtEveryXYears")
                    formFrequencyDueEnd = collection("txtEveryXYearsDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        reqToEdit.Frequency = Integer.Parse(formFrequency)
                        reqToEdit.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXMonth Then
                    formFrequency = collection("txtEveryXMonth")
                    formFrequencyDueEnd = collection("txtEveryXMonthDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        reqToEdit.Frequency = Integer.Parse(formFrequency)
                        reqToEdit.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXDays Then
                    formFrequency = collection("txtEveryXDays")
                    formFrequencyDueEnd = collection("txtEveryXDaysDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        reqToEdit.Frequency = Integer.Parse(formFrequency)
                        reqToEdit.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.TwiceDaily Then
                    Dim firstTime As String = collection("txtTwiceDailyFirstTime")
                    Dim secondTime As String = collection("txtTwiceDailySecondTime")
                    If ValidateTime(formFrequencyType, firstTime) AndAlso ValidateTime(formFrequencyType, secondTime) Then
                        reqToEdit.FirstTime = DateTime.Parse(firstTime)
                        reqToEdit.SecondTime = DateTime.Parse(secondTime)
                    End If
                    reqToEdit.Frequency = New Nullable(Of Integer)
                    reqToEdit.FrequencyDueEnd = New Nullable(Of Integer)
                ElseIf formFrequencyType = RequirementFrequency.WhenUsed Then
                    reqToEdit.Frequency = New Nullable(Of Integer)
                    reqToEdit.FrequencyDueEnd = New Nullable(Of Integer)
                    reqToEdit.FirstTime = New Nullable(Of DateTime)
                    reqToEdit.SecondTime = New Nullable(Of DateTime)
                End If


                If Not ModelState.IsValid Then
                    InitControls(reqToEdit)
                    Return View()
                End If

                reqToEdit.Save()

                If oldAssetType <> reqToEdit.AssetType.Description Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_MODIFICATION_TEMPLATE, "Asset Type", oldAssetType, reqToEdit.AssetType.Description))
                End If

                If reqToEdit.FrequencyDueEnd <> oldFrequencyDueEnd Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_MODIFICATION_TEMPLATE, "Frequency", oldFrequencyDueEnd, reqToEdit.FrequencyDueEnd))
                End If



                ModificationHistory.Insert(EntityType.Requirement, reqToEdit.Name, ModificationAction.Modified, Application.CurrentUserInfo.UserID, changeDetails, reqToEdit.ID)
                NotificationManager.CreateNotificationsByTrigger(NotificationTrigger.Requirement_Modify, reqToEdit.Name)

            Catch ex As Exception
                InitControls(reqToEdit)
                Return View()
            End Try
            Return RedirectToAction("Index")
        End Function
#End Region

#Region "Create"
        Function Create() As ActionResult
            InitControls(New Requirement())
            Return View()
        End Function

        <HttpPost()> _
        Function Create(ByVal collection As FormCollection) As ActionResult
            Dim formMaxId As Integer = Integer.Parse(collection("maxId"))
            Dim formRequirementName As String = collection("RequirementName")
            Dim formRequirementType As RequirementType = [Enum].Parse(GetType(RequirementType), collection("RequirementType"))
            Dim formAssetTypeID As Integer = Integer.Parse(collection("AssetType"))
            Dim formFrequencyType As RequirementFrequency = [Enum].Parse(GetType(RequirementFrequency), collection("rbFrequency"))
            Dim formUseNotHolidayWeekday As Boolean = Boolean.Parse(collection("cbxNotHolidayWeekday").Split(",")(0))
            Dim formUseSaturdays As Boolean = Boolean.Parse(collection("cbxSaturdays").Split(",")(0))
            Dim formUseSundays As Boolean = Boolean.Parse(collection("cbxSundays").Split(",")(0))
            Dim formUseHoliday As Boolean = Boolean.Parse(collection("cbxHoliday").Split(",")(0))

            Dim changeDetails As New List(Of String)

            Dim formFrequency As String
            Dim formFrequencyDueEnd As String

            Dim req As New Requirement()

            Try
                If String.IsNullOrEmpty(formRequirementName) Then
                    ModelState.AddModelError("RequirementName", "Basic Requirement Name is required.")
                End If

                req.Name = formRequirementName
                req.AssetTypeID = formAssetTypeID
                req.Type = formRequirementType
                req.FrequencyType = formFrequencyType
                req.UseNotHolidayWeekday = formUseNotHolidayWeekday
                req.UseSaturdays = formUseSaturdays
                req.UseSundays = formUseSundays
                req.UseHoliday = formUseHoliday
                req.CreatedDate = DateTime.UtcNow
                req.CreatedBy = Application.CurrentUserInfo.UserID

                If Not String.IsNullOrEmpty(formRequirementName) Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_SET_TEMPLATE, "Requirement Name", formRequirementName))
                End If

                If Not String.IsNullOrEmpty(formRequirementName) Then
                    changeDetails.Add(String.Format(Constants.UI.FIELD_SET_TEMPLATE, "Asset Type", AssetType.GetByPrimaryKey(formAssetTypeID).Description))
                End If

                changeDetails.Add(String.Format(Constants.UI.FIELD_SET_TEMPLATE, "Requirement Type", formRequirementType.ToString()))

                For i As Integer = 1 To formMaxId

                    Dim formMeasureName As String = collection(String.Format("measureName_{0}", i))

                    If Not String.IsNullOrEmpty(formMeasureName) Then

                        Dim measure As New RequirementMeasure()

                        Dim formMeasureOptimalLookupValue As String = collection(String.Format("measureOptimalLookupValue_{0}", i))
                        Dim formMeasureOptimalMin As String = collection(String.Format("measureOptimalMin_{0}", i))
                        Dim formMeasureOptimalMax As String = collection(String.Format("measureOptimalMax_{0}", i))
                        Dim formMeasureType As MeasureType = [Enum].Parse(GetType(MeasureType), collection(String.Format("measureType_{0}", i)))
                        Dim formMeasureLookupValue As String = collection(String.Format("measureLookupValue_{0}", i))
                        Dim formMeasureRequiredComments As String = collection(String.Format("measureRequiredComments_{0}", i))

                        measure.MeasureDescription = formMeasureName
                        measure.MeasureType = CInt(formMeasureType)
                        measure.LookupValue = formMeasureLookupValue
                        measure.OptimalLookupValue = formMeasureOptimalLookupValue

                        If formMeasureType = MeasureType.Integer Then
                            measure.IntegerMin = Integer.Parse(formMeasureOptimalMin)
                            measure.IntegerMax = Integer.Parse(formMeasureOptimalMax)
                        ElseIf formMeasureType = MeasureType.Decimal Then
                            measure.DecimalMin = Decimal.Parse(formMeasureOptimalMin)
                            measure.DecimalMax = Decimal.Parse(formMeasureOptimalMax)
                        End If

                        measure.RequiredComments = Integer.Parse(formMeasureRequiredComments)

                        req.Measures.Add(measure)
                        changeDetails.Add(String.Format(Constants.UI.FIELD_ADD_MEASURE_TEMPLATE, measure.MeasureDescription, formMeasureType.ToString()))

                    End If

                Next

                req.FirstTime = New Nullable(Of DateTime)
                req.SecondTime = New Nullable(Of DateTime)

                If formFrequencyType = RequirementFrequency.EveryXHours Then
                    formFrequency = collection("txtEveryXHours")
                    formFrequencyDueEnd = collection("txtEveryXHoursDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        req.Frequency = Integer.Parse(formFrequency)
                        req.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXWeeks Then
                    formFrequency = collection("txtEveryXWeeks")
                    formFrequencyDueEnd = collection("txtEveryXWeeksDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        req.Frequency = Integer.Parse(formFrequency)
                        req.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXYears Then
                    formFrequency = collection("txtEveryXYears")
                    formFrequencyDueEnd = collection("txtEveryXYearsDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        req.Frequency = Integer.Parse(formFrequency)
                        req.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXMonth Then
                    formFrequency = collection("txtEveryXMonth")
                    formFrequencyDueEnd = collection("txtEveryXMonthDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        req.Frequency = Integer.Parse(formFrequency)
                        req.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.EveryXDays Then
                    formFrequency = collection("txtEveryXDays")
                    formFrequencyDueEnd = collection("txtEveryXDaysDueEnd")
                    If ValidateFrequency(formFrequencyType, formFrequency, formFrequencyDueEnd) Then
                        req.Frequency = Integer.Parse(formFrequency)
                        req.FrequencyDueEnd = Integer.Parse(formFrequencyDueEnd)
                    End If
                ElseIf formFrequencyType = RequirementFrequency.TwiceDaily Then
                    Dim firstTime As String = collection("txtTwiceDailyFirstTime")
                    Dim secondTime As String = collection("txtTwiceDailySecondTime")
                    If ValidateTime(formFrequencyType, firstTime) AndAlso ValidateTime(formFrequencyType, secondTime) Then
                        req.FirstTime = DateTime.Parse(firstTime)
                        req.SecondTime = DateTime.Parse(secondTime)
                    End If
                    req.Frequency = New Nullable(Of Integer)
                    req.FrequencyDueEnd = New Nullable(Of Integer)
                ElseIf formFrequencyType = RequirementFrequency.WhenUsed Then
                    req.Frequency = New Nullable(Of Integer)
                    req.FrequencyDueEnd = New Nullable(Of Integer)
                    req.FirstTime = New Nullable(Of DateTime)
                    req.SecondTime = New Nullable(Of DateTime)
                End If


                If Not ModelState.IsValid Then
                    InitControls(req)
                    Return View()
                End If

                Requirement.Insert(req)
                ModificationHistory.Insert(EntityType.Requirement, req.Name, ModificationAction.Created, Application.CurrentUserInfo.UserID, changeDetails, req.ID)
                NotificationManager.CreateNotificationsByTrigger(NotificationTrigger.Requirement_Create, req.Name)

            Catch ex As Exception

            End Try

            InitControls(req)

            Return RedirectToAction("Index")
        End Function
#End Region

#Region "Private Section"
        Private Function ValidateFrequency(ByVal frequencyType As RequirementFrequency, ByVal frequency As String, ByVal frequencyDueEnd As String) As Boolean
            Dim frequencyValue As Integer = 0
            Dim frequencyDueEndValue As Integer = 0
            Dim result As Boolean = True

            If Not Integer.TryParse(frequency, frequencyValue) Then
                ModelState.AddModelError(frequencyType.ToString(), "X Value is required.")
                result = False
            End If

            If Not Integer.TryParse(frequencyDueEnd, frequencyDueEndValue) Then
                ModelState.AddModelError(frequencyType.ToString() & "DueEnd", "Due end Value is required.")
                result = False
            End If

            Return result
        End Function

        Private Function ValidateTime(ByVal frequencyType As RequirementFrequency, ByVal time As String) As Boolean
            Dim timeValue As DateTime = DateTime.Now

            If String.IsNullOrEmpty(time) Then
                ModelState.AddModelError(frequencyType.ToString(), "Time is required.")
                Return False
            End If

            If Not DateTime.TryParse(time, timeValue) Then
                ModelState.AddModelError(frequencyType.ToString(), "Invalid date format.")
                Return False
            End If

            Return True
        End Function

        Private Sub InitControls(ByRef req As Requirement)
            ViewData("ID") = req.ID
            ViewData("RequirementName") = req.Name
            ViewData("AssetType") = New SelectList(AssetType.RetrieveAll(), "ID", "Description", req.AssetTypeID)
            ViewData("RequirementType") = New SelectList(RequirementTypeLookup.RetrieveAll(), "ID", "Description", req.Type)

            ViewData("MeasureList") = req.Measures
            ViewData("MaxID") = req.Measures.Count
            ViewData(String.Format("SelectedFreq{0}", CType(req.FrequencyType, RequirementFrequency).ToString())) = True

            If req.UseHoliday Then
                ViewData("SelectedHoliday") = True
            End If
            If req.UseNotHolidayWeekday Then
                ViewData("SelectedNotHolidayWeekday") = True
            End If
            If req.UseSaturdays Then
                ViewData("SelectedSaturdays") = True
            End If
            If req.UseSundays Then
                ViewData("SelectedSundays") = True
            End If


            If req.FrequencyType = RequirementFrequency.EveryXHours Then
                ViewData("EveryXHours") = req.Frequency
                ViewData("EveryXHoursDueEnd") = req.FrequencyDueEnd
            ElseIf req.FrequencyType = RequirementFrequency.EveryXWeeks Then
                ViewData("EveryXWeeks") = req.Frequency
                ViewData("EveryXWeeksDueEnd") = req.FrequencyDueEnd
            ElseIf req.FrequencyType = RequirementFrequency.EveryXYears Then
                ViewData("EveryXYears") = req.Frequency
                ViewData("EveryXYearsDueEnd") = req.FrequencyDueEnd
            ElseIf req.FrequencyType = RequirementFrequency.EveryXMonth Then
                ViewData("EveryXMonth") = req.Frequency
                ViewData("EveryXMonthDueEnd") = req.FrequencyDueEnd
            ElseIf req.FrequencyType = RequirementFrequency.EveryXDays Then
                ViewData("EveryXDays") = req.Frequency
                ViewData("EveryXDaysDueEnd") = req.FrequencyDueEnd
            ElseIf req.FrequencyType = RequirementFrequency.TwiceDaily Then
                ViewData("TwiceDailyFirstTime") = If(req.FirstTime.HasValue, req.FirstTime.Value.ToString("hh:mm tt"), Nothing)
                ViewData("TwiceDailySecondTime") = If(req.SecondTime.HasValue, req.SecondTime.Value.ToString("hh:mm tt"), Nothing)
            End If

        End Sub
#End Region

#Region "AJAX"
        <HttpPost()> _
        Function FilterRequirement(ByVal assetTypeID As Integer?, ByVal frequency As String) As ActionResult
            If Not assetTypeID.HasValue Then
                assetTypeID = 0
            End If

            Dim requirements As IEnumerable(Of Requirement)

            If String.IsNullOrEmpty(frequency) Then
                requirements = Requirement.RetrieveAll(assetTypeID)
            Else
                Dim frequencyList = RequirementFrequencyHelper.GetListByFrequencyString(frequency)
                requirements = Requirement.RetrieveAll(assetTypeID, frequencyList)
            End If

            ViewData("Requirements") = requirements

            Return PartialView("~/Views/BasicRequirements/Controls/RequirementGrid.ascx")
        End Function

#End Region

    End Class
End Namespace